package com.itheima.mapper;

import com.itheima.entity.Emp;
import com.itheima.entity.EmpParam;
import com.itheima.entity.Login;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmpMapper {
   /* //统计员工总记录数
    @Select("select count(*)from emp;")
    long count();
    //分页查询
    @Select("select e.*,d.name as deptName from emp e left join dept d on e.dept_id = d.id limit #{i},#{pageSize};")
    List<Emp> page(Integer i, Integer pageSize);
*/

    //列表查询
    //@Select("select e.*,d.name as deptName from emp e left join dept d on e.dept_id = d.id")
    //基于xml开发动态sql

    List<Emp> listEmp(EmpParam empParam);
    //新增员工基本信息
    @Options(useGeneratedKeys = true,keyProperty = "id")//获取主键值并赋值给id属性
    @Insert("insert into emp  values (null,#{username},#{password},#{name},#{gender}," +
            "#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void addEmp(Emp emp);
    //批量删除员工信息
    //基于xml开发动态sql
    void deleteBatch(List<Integer> ids);
    //批量删除员工经历
    void deleteExprBatch(List<Integer> ids);
    //根据id查询员工基本信息和工作经历
    Emp getById(Integer id);
    @Select("select *from emp where id=#{id}")
    Emp getById2(Integer id);
    //更新员工基本信息（动态sql）
    void update(Emp emp);
    //查询所有员工
   List <Emp> getList();
    //员工登录
    @Select("select *from emp where username=#{username} and password=#{password}")
    Emp login(Emp emp);


}
